import axios from "axios";

let http = axios.create({
  baseURL: "http://43.129.181.211:9999",
  //   http://43.129.181.211:9003
  timeout: 5000,
  headers: {
    "Content-Type": "application/json",
  },
});
http.interceptors.request.use(
  (config) => {
    config.headers.Authorization = "666";
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

http.interceptors.response.use(
  (response) => {
    // 对响应数据做处理
    return response.data;
  },
  (error) => {
    // 处理响应错误，比如根据错误状态码给出提示
    //   const { status } = error.response || {};
    //   if (status === 401) {
    //     console.error('未授权，请重新登录');
    //   } else {
    //     console.error('请求出错:', error.message);
    //   }
    return Promise.reject(error);
  }
);

export default http;
